home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / msgbox / msgedit.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1995-05-08  |  8.5 KB  |  269 lines

  1. VERSION 2.00
  2. Begin Form MsgEdit 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "MsgBox Editor"
  5.    ClientHeight    =   4155
  6.    ClientLeft      =   1605
  7.    ClientTop       =   1965
  8.    ClientWidth     =   5550
  9.    ForeColor       =   &H00000000&
  10.    Height          =   4845
  11.    Left            =   1545
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   4155
  17.    ScaleWidth      =   5550
  18.    Top             =   1335
  19.    Width           =   5670
  20.    Begin CommandButton Finished 
  21.       Caption         =   "&Finished!"
  22.       FontBold        =   -1  'True
  23.       FontItalic      =   0   'False
  24.       FontName        =   "MS Sans Serif"
  25.       FontSize        =   12
  26.       FontStrikethru  =   0   'False
  27.       FontUnderline   =   0   'False
  28.       Height          =   495
  29.       Left            =   1920
  30.       TabIndex        =   6
  31.       Top             =   3480
  32.       Width           =   1815
  33.    End
  34.    Begin CommandButton MessageClear 
  35.       Caption         =   "Clear"
  36.       Height          =   495
  37.       Left            =   4680
  38.       TabIndex        =   5
  39.       Top             =   2640
  40.       Width           =   615
  41.    End
  42.    Begin CommandButton MessageOK 
  43.       Caption         =   "OK"
  44.       Height          =   495
  45.       Left            =   4680
  46.       TabIndex        =   4
  47.       Top             =   2040
  48.       Width           =   615
  49.    End
  50.    Begin TextBox MessageEdit 
  51.       Height          =   855
  52.       Left            =   240
  53.       MultiLine       =   -1  'True
  54.       TabIndex        =   3
  55.       Top             =   2040
  56.       Width           =   4215
  57.    End
  58.    Begin CommandButton TitleClear 
  59.       Caption         =   "Clear"
  60.       Height          =   495
  61.       Left            =   4680
  62.       TabIndex        =   2
  63.       Top             =   1200
  64.       Width           =   615
  65.    End
  66.    Begin CommandButton TitleOK 
  67.       Caption         =   "OK"
  68.       Height          =   495
  69.       Left            =   4680
  70.       TabIndex        =   1
  71.       Top             =   600
  72.       Width           =   615
  73.    End
  74.    Begin TextBox TitleEdit 
  75.       Height          =   375
  76.       Left            =   240
  77.       TabIndex        =   0
  78.       Top             =   600
  79.       Width           =   4215
  80.    End
  81.    Begin Label Label3 
  82.       Caption         =   "Use Return to start new line, and Control-Return (or click on OK) to accept text."
  83.       FontBold        =   0   'False
  84.       FontItalic      =   0   'False
  85.       FontName        =   "MS Sans Serif"
  86.       FontSize        =   8.25
  87.       FontStrikethru  =   0   'False
  88.       FontUnderline   =   0   'False
  89.       Height          =   375
  90.       Index           =   1
  91.       Left            =   240
  92.       TabIndex        =   10
  93.       Top             =   3000
  94.       Width           =   4215
  95.    End
  96.    Begin Label Label1 
  97.       Caption         =   "Enter MsgBox &Message Here:"
  98.       FontBold        =   -1  'True
  99.       FontItalic      =   0   'False
  100.       FontName        =   "MS Sans Serif"
  101.       FontSize        =   12
  102.       FontStrikethru  =   0   'False
  103.       FontUnderline   =   0   'False
  104.       Height          =   375
  105.       Left            =   360
  106.       TabIndex        =   7
  107.       Top             =   1560
  108.       Width           =   3855
  109.    End
  110.    Begin Label Label3 
  111.       Caption         =   "Use Control-Return (or click on OK) to accept text."
  112.       FontBold        =   0   'False
  113.       FontItalic      =   0   'False
  114.       FontName        =   "MS Sans Serif"
  115.       FontSize        =   8.25
  116.       FontStrikethru  =   0   'False
  117.       FontUnderline   =   0   'False
  118.       Height          =   255
  119.       Index           =   0
  120.       Left            =   240
  121.       TabIndex        =   9
  122.       Top             =   1080
  123.       Width           =   4215
  124.    End
  125.    Begin Label Label2 
  126.       Caption         =   "Enter MsgBox &Title Here:"
  127.       FontBold        =   -1  'True
  128.       FontItalic      =   0   'False
  129.       FontName        =   "MS Sans Serif"
  130.       FontSize        =   12
  131.       FontStrikethru  =   0   'False
  132.       FontUnderline   =   0   'False
  133.       ForeColor       =   &H00000000&
  134.       Height          =   375
  135.       Left            =   360
  136.       TabIndex        =   8
  137.       Top             =   120
  138.       Width           =   4095
  139.    End
  140.    Begin Menu Hints 
  141.       Caption         =   "&Hints"
  142.       Begin Menu TitleMsg 
  143.          Caption         =   "&Title..."
  144.       End
  145.       Begin Menu MsgMsg 
  146.          Caption         =   "&Message..."
  147.       End
  148.       Begin Menu EditMsg 
  149.          Caption         =   "&Editing..."
  150.       End
  151.       Begin Menu sep 
  152.          Caption         =   "-"
  153.       End
  154.       Begin Menu AboutMsg 
  155.          Caption         =   "&About..."
  156.       End
  157.    End
  158. Sub AboutMsg_Click ()
  159.     MBAbout.Show
  160. End Sub
  161. Function CheckString (TheText As String, TheType As Integer)
  162.     CheckString = True
  163.     StrMsg$ = "VB will will truncate this long word at the 255th character.  Try again!"
  164.     LenMsg$ = "VB will only allow 1,024 characters in a message box.  Try again!"
  165.     WordText$ = TheText
  166.     While InStr(WordText$, Chr$(32)) > 0
  167.     If InStr(WordText$, Chr$(32)) > 255 Then
  168.         MsgBox StrMsg$, 16, "String Error"
  169.         CheckString = False
  170.     End If
  171.     WordText$ = Mid$(WordText$, InStr(WordText$, Chr$(32)) + 1)
  172.     Wend
  173.     If Len(TheText) > 1024 And TheType = MSG Then
  174.     MsgBox LenMsg$, 16, "String Error"
  175.     CheckString = False
  176.     End If
  177. End Function
  178. Sub EditMsg_Click ()
  179.     CR$ = Chr$(13) + Chr$(10)
  180.     Q$ = Chr$(34)
  181.     TheMessage$ = "Instructions for editing are placed below the edit boxes.  You may embed carriage returns"
  182.     TheMessage$ = TheMessage$ + " in the Message section by pressing Return.  You can accept the text by pressing Control-Return in either the Title or"
  183.     TheMessage$ = TheMessage$ + " the Message Box. You may also use a mouse to click on the OK buttons and the Finished button."
  184.     TheStyle = 0
  185.     TheTitle$ = "Editing"
  186.     MsgBox TheMessage, TheStyle, TheTitle
  187. End Sub
  188. Sub Finished_Click ()
  189.     If Len(RawMessage) > 0 Then
  190.     MsgEdit.Hide
  191.     MsgBxGen.Show
  192.     MsgBxGen.CopyCtl.SetFocus
  193.     Else
  194.     AnAnswer = MsgBox("What good's a message box without a message?", 37, "String Error")
  195.     If AnAnser = RETRY Then
  196.         Exit Sub
  197.     Else
  198.         End
  199.     End If
  200.     End If
  201. End Sub
  202. Sub MessageClear_Click ()
  203.     MessageEdit.Text = ""
  204. End Sub
  205. Sub MessageEdit_KeyUp (KeyCode As Integer, Shift As Integer)
  206.     CtrlDown% = (Shift And CTRL_MASK) > 0
  207.     If KeyCode = KEY_RETURN Then    ' Display key combinations.
  208.     If CtrlDown% Then
  209.         StringState = CheckString((MessageEdit.Text), MSG)
  210.         If StringState <> False Then
  211.         RawMessage = Left$(MessageEdit.Text, Len(MessageEdit.Text) - 2)
  212.         End If
  213.         If Len(RawMessage) > 0 Then
  214.         Finished.SetFocus
  215.         Else
  216.         AnAnswer = MsgBox("What good's a message box without a message?", 37, "String Error")
  217.         If AnAnser = RETRY Then
  218.             Exit Sub
  219.         Else
  220.             End
  221.         End If
  222.         End If
  223.     End If
  224.     End If
  225. End Sub
  226. Sub MessageOK_Click ()
  227.     StringState = CheckString((MessageEdit.Text), MSG)
  228.     If StringState <> False Then
  229.     RawMessage = MessageEdit.Text
  230.     End If
  231.     Finished.SetFocus
  232. End Sub
  233. Sub MsgMsg_Click ()
  234.     CR$ = Chr$(13) + Chr$(10)
  235.     Q$ = Chr$(34)
  236.     TheMessage$ = "The message box function/procedure will only accept messages 1,024 characters"
  237.     TheMessage$ = TheMessage$ + " long.  Longer messages will be truncated at the 1,024th character.  Words (any series of characters without intervening spaces) will be truncated at the 255th character."
  238.     TheStyle = 0
  239.     TheTitle$ = "The Message"
  240.     MsgBox TheMessage, TheStyle, TheTitle
  241. End Sub
  242. Sub TitleClear_Click ()
  243.     TitleEdit.Text = ""
  244. End Sub
  245. Sub TitleEdit_KeyUp (KeyCode As Integer, Shift As Integer)
  246.     CtrlDown% = (Shift And CTRL_MASK) > 0
  247.     If KeyCode = KEY_RETURN Then    ' Display key combinations.
  248.     If CtrlDown% Then
  249.         TheTitle = TitleEdit.Text
  250.         MessageEdit.SetFocus
  251.     End If
  252.     End If
  253. End Sub
  254. Sub TitleMsg_Click ()
  255.     CR$ = Chr$(13) + Chr$(10)
  256.     Q$ = Chr$(34)
  257.     TheMessage$ = "Any word (series of characters with no intervening spaces) is truncated at the 255th character.  Titles longer than the width of the monitor are not very helpful as messages."
  258.     TheStyle = 0
  259.     TheTitle$ = "The Title"
  260.     MsgBox TheMessage, TheStyle, TheTitle
  261. End Sub
  262. Sub TitleOK_Click ()
  263.     TheTitle = TitleEdit.Text
  264.     TheAnswer = CheckString(TheTitle, TTL)
  265.     If TheAnswer <> False Then
  266.     MessageEdit.SetFocus
  267.     End If
  268. End Sub
  269.